home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994…tember: Reference Library / Dev.CD Sep 94.toast / Technical Documentation / C.S.M.P. Digests / csmp-digest-v3-039 / doubleCR.1 < prev   
Encoding:
Text File  |  1994-07-07  |  55.8 KB  |  1,669 lines

  1. C.S.M.P. Digest             Sun, 26 Jun 94       Volume 3 : Issue 39
  2.  
  3. Today's Topics:
  4.  
  5.         API-headers for Control Strip Modules?
  6.         Apple Event Question
  7.         Are NewPtr() and malloc() different? (source included)
  8.         Closing Down the FINDER
  9.         Fat-stripping
  10.         Finder Comments and Finder Info Updating
  11.         MacTech's ftp site now available!
  12.         QuickDraw GX Display Devices
  13.         SEMI-SUMMARY: Reading JPEGs (with code)
  14.         VBL interrupt & Stack Sniffer
  15.         Writing dcmd with Think C (Q)
  16.  
  17.  
  18.  
  19. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  20. (pottier@clipper.ens.fr).
  21.  
  22. The digest is a collection of article threads from the internet newsgroup
  23. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  24. regularly and want an archive of the discussions.  If you don't know what a
  25. newsgroup is, you probably don't have access to it.  Ask your systems
  26. administrator(s) for details.  If you don't have access to news, you may
  27. still be able to post messages to the group by using a mail server like
  28. anon.penet.fi (mail help@anon.penet.fi for more information).
  29.  
  30. Each issue of the digest contains one or more sets of articles (called
  31. threads), with each set corresponding to a 'discussion' of a particular
  32. subject.  The articles are not edited; all articles included in this digest
  33. are in their original posted form (as received by our news server at
  34. nef.ens.fr).  Article threads are not added to the digest until the last
  35. article added to the thread is at least two weeks old (this is to ensure that
  36. the thread is dead before adding it to the digest).  Article threads that
  37. consist of only one message are generally not included in the digest.
  38.  
  39. The digest is officially distributed by two means, by email and ftp.
  40.  
  41. If you want to receive the digest by mail, send email to listserv@ens.fr
  42. with no subject and one of the following commands as body:
  43.     help                        Sends you a summary of commands
  44.     subscribe csmp-digest Your Name    Adds you to the mailing list
  45.     signoff csmp-digest            Removes you from the list
  46. Once you have subscribed, you will automatically receive each new
  47. issue as it is created.
  48.  
  49. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  50. Questions related to the ftp site should be directed to
  51. scott.silver@dartmouth.edu. Currently no previous volumes of the CSMP
  52. digest are available there.
  53.  
  54. Also, the digests are available to WAIS users.  To search back issues
  55. with WAIS, use comp.sys.mac.programmer.src. With Mosaic, use
  56. http://www.wais.com/wais-dbs/comp.sys.mac.programmer.html.
  57.  
  58.  
  59. -------------------------------------------------------
  60.  
  61. >From Gordie Freedman <gordie@kaleida.com>
  62. Subject: API-headers for Control Strip Modules?
  63. Date: 8 Jun 1994 07:17:19 GMT
  64. Organization: Kaleida Labs, Inc.
  65.  
  66. Anybody know where the API is documented to write control strip modules?
  67. I also wasn't sure if there were any header files you used with this
  68. stuff, or if you had to roll your own. Thanks in advance,
  69.  
  70. Gordie Freedman
  71. --
  72.  
  73. gordie@kaleida.com - Kaleida Labs, Inc. - Mountain View, CA
  74.  
  75. +++++++++++++++++++++++++++
  76.  
  77. >From tgaul@halcyon.com (Troy Gaul)
  78. Date: Wed, 08 Jun 1994 21:42:50 -0700
  79. Organization: Infinity Systems
  80.  
  81. In article <2t3r9v$3mr@golden.kaleida.com>, Gordie Freedman
  82. <gordie@kaleida.com> wrote:
  83.  
  84. > Anybody know where the API is documented to write control strip modules?
  85. > I also wasn't sure if there were any header files you used with this
  86. > stuff, or if you had to roll your own. Thanks in advance,
  87.  
  88. They're in the PowerBook 500-series technical notes, which were included on
  89. the June Developer CD.  As far as a header file goes, I didn't see anything
  90. included.
  91.  
  92. _troy
  93. //////// //////___Troy Gaul_________________________tgaul@halcyon.com__ //
  94.   //    //       Infinity Systems ; Redmond, Washington                //
  95.  //    //  //  "Insert witty quote here."                             //
  96. //    //////________________________________________________________ //
  97.  
  98. +++++++++++++++++++++++++++
  99.  
  100. >From jonpugh@netcom.com (Jon Pugh)
  101. Date: Sat, 11 Jun 1994 09:12:12 GMT
  102. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  103.  
  104. Gordie Freedman (gordie@kaleida.com) wrote:
  105. > Anybody know where the API is documented to write control strip modules?
  106. > I also wasn't sure if there were any header files you used with this
  107. > stuff, or if you had to roll your own. Thanks in advance,
  108.  
  109. For that matter, can you get the software any way without buying a 500?
  110.  
  111. Not that I don't want a 500...
  112.  
  113. Jon
  114.  
  115. +++++++++++++++++++++++++++
  116.  
  117. >From tgaul@halcyon.com (Troy Gaul)
  118. Date: Sat, 11 Jun 1994 22:46:33 -0700
  119. Organization: Infinity Systems
  120.  
  121. In article <jonpughCr86wC.LBA@netcom.com>, jonpugh@netcom.com (Jon Pugh)
  122. wrote:
  123.  
  124. > Gordie Freedman (gordie@kaleida.com) wrote:
  125. > > Anybody know where the API is documented to write control strip modules?
  126. > > I also wasn't sure if there were any header files you used with this
  127. > > stuff, or if you had to roll your own. Thanks in advance,
  128. > For that matter, can you get the software any way without buying a 500?
  129. > Not that I don't want a 500...
  130.  
  131. I tried a copy of Control Strip, grabbed off the hard drive of a 500, and
  132. tried it on a desktop Mac, and it wouldn't function, but it worked fine on
  133. a PowerBook 140.  
  134.  
  135. I certainly hope that they allow it to work on desktop Macs as well soon. 
  136. I'd like to use it for a few things myself (like volume and monitor
  137. depth-switching), and its modular architecture makes it easy for third
  138. parties to write modules that would be useful for users of desktop
  139. machines.
  140.  
  141. _troy
  142. //////// //////___Troy Gaul_________________________tgaul@halcyon.com__ //
  143.   //    //       Infinity Systems ; Redmond, Washington                //
  144.  //    //  //  "Insert witty quote here."                             //
  145. //    //////________________________________________________________ //
  146.  
  147. +++++++++++++++++++++++++++
  148.  
  149. >From quinn@cs.uwa.edu.au (Quinn "The Eskimo!")
  150. Date: Sun, 12 Jun 1994 14:54:34 +0800
  151. Organization: Department of Computer Science, The University of Western Australia
  152.  
  153. In article <jonpughCr86wC.LBA@netcom.com>, jonpugh@netcom.com (Jon Pugh) wrote:
  154.  
  155. >For that matter, can you get the software any way without buying a 500?
  156.  
  157. Yes.  Get a 280 (:
  158. -- 
  159. Quinn "The Eskimo!"      <quinn@cs.uwa.edu.au>     "Support HAVOC!"
  160. Department of Computer Science, The University of Western Australia
  161.  
  162. +++++++++++++++++++++++++++
  163.  
  164. >From quinn@cs.uwa.edu.au (Quinn "The Eskimo!")
  165. Date: Sun, 12 Jun 1994 23:08:17 +0800
  166. Organization: Department of Computer Science, The University of Western Australia
  167.  
  168. In article <tgaul-110694224633@bellevue-ip68.halcyon.com>,
  169. tgaul@halcyon.com (Troy Gaul) wrote:
  170.  
  171. >I tried a copy of Control Strip, grabbed off the hard drive of a 500, and
  172. >tried it on a desktop Mac, and it wouldn't function, but it worked fine on
  173. >a PowerBook 140.  
  174.  
  175. The guys at the WWDC session said they would consider moving it to the
  176. desktop Macs depending on how it was received on the PowerBooks. 
  177. Personally I think it's a TOE (Thing Of Evil (tm)).  That won't stop me
  178. using it of course (:
  179. -- 
  180. Quinn "The Eskimo!"      <quinn@cs.uwa.edu.au>     "Support HAVOC!"
  181. Department of Computer Science, The University of Western Australia
  182.   Now if only the 280C I have on order would arrive ):
  183.  
  184. ---------------------------
  185.  
  186. >From jml16@po.CWRU.Edu (Jonathon M. Lipsky)
  187. Subject: Apple Event Question
  188. Date: 2 Jun 1994 20:01:16 GMT
  189. Organization: Case Western Reserve University, Cleveland, Ohio (USA)
  190.  
  191.  
  192. I would like to know if anyone has created their own
  193. AppleEvents to pass data between two programs.  What
  194. I would like to do is impliment an event similar to
  195. an OpenDocument, but I would like to pass a string
  196. that the recieving program that would give it the
  197. needed information.  All of my attempts at implimenting
  198. this have not succeeded, so any examples would be
  199. greatly appreciated.
  200.  
  201. Jon Lipsky (jml16@po.cwru.edu)
  202.  
  203. +++++++++++++++++++++++++++
  204.  
  205. >From Here@There (Someone)
  206. Date: 10 Jun 1994 17:29:50 GMT
  207. Organization: Large Fuzzy Room
  208.  
  209. There's lots of samples around, adapting a 'real' AppleEvent to your
  210. private needs will be easiest.  Here's one way you might want to implement
  211. the send and recieve functions (VERY simple here)
  212.  
  213. // a coupla defines
  214. #define kMyPrivateEventClass 'MYEV'
  215. #define kOpenFileStringEvent 'OPFS'
  216. #define typeMyPString 'MPST'
  217. // Get the address (through PPCBrowser or elsewhere) and the 
  218. // file string and pass them in
  219. OSErr SendFileNameString(ConstStr255 theFullPath,AEDesc * theAddress)
  220. {
  221. AppleEvent theEvent;
  222. OSErr theError = noErr;
  223. // create the event
  224. theError = AECreateAppleEvent(kMyPrivateEventClass,kOpenFileStringEvent,
  225. theAddress,kAutoGenerateReturnID,kAnyTransactionID,&theEvent);
  226. // if no error, add our string
  227. if(theError == noErr)
  228. theError=
  229. AEPutParamPtr(&theEvent,keyDirectObject,typeMyPString,(Ptr)&theFullPath[1],theFullPath[0]);
  230. // send the event
  231. if(theError == noErr)
  232. theError =
  233. AESend(&theEvent,nil,kAENoReply,kAENormalPriority,kAEDefaultTimeout,(IdleProcPtr)
  234. nil,nil);
  235.  
  236. return( theError );
  237. }
  238.  
  239.  
  240. // and on the recieving end, get the thing out
  241.  
  242. pascal OSErr HandleMyOpenFileStr(AppleEvent *messagein, AppleEvent *reply,
  243. long refIn)
  244. {OSErr theError = noErr;
  245. Str255 fileString;
  246. DescType returnedType;
  247. Size returnedSize;
  248. // get the string from the event
  249. theError = AEGetParamPtr(messagein,   // from this event
  250.                            keyDirectObject,    // get the direct object
  251.                            typeMyPString,       // as a pstring
  252.                            &returnedType,     
  253.                            (Ptr)&fileString[1],  // put it here
  254.                            254,      // max size
  255.                            &returnedSize);
  256. if(theError == noErr){
  257. fileString[0] = returnedSize;
  258. theError  = FSOpen(fileString, nil,&fileRefNum);
  259. // fileRefNum is somewhere, whereever you need it
  260. }
  261. return ( theError);
  262. }
  263.  
  264. ---------------------------
  265.  
  266. >From cr@cs.strath.ac.uk (Chris Reid)
  267. Subject: Are NewPtr() and malloc() different? (source included)
  268. Date: Mon, 06 Jun 1994 12:15:52 +0000
  269. Organization: University of Strathclyde
  270.  
  271. Hi everybody,
  272.  
  273. I have written some code that implements Radix Sort (it sorts
  274. an array of longs in linear time). It seems to work well enough,
  275. but one thing is really strange: when I replace the NewPtr()
  276. calls with calls to malloc(), the corresponding free() doesn't seem
  277. to work. Here's roughly what happens:
  278.  
  279.  
  280. // RadixSort implemented using NewPtr() and DisposPtr()
  281.  
  282. mem = FreeMem();    // We've got amount 'mem' bytes in the heap
  283. RadixSort(someArray, numItems);    // Do the sorting
  284. waste = mem - FreeMem();    // Is there a memory leak?
  285.  
  286. waste is always zero (just as it should be), BUT:
  287.  
  288. // RadixSort implemented using malloc() and free()
  289.  
  290. mem = FreeMem();    // We've got amount 'mem' bytes in the heap
  291. RadixSort(someArray, numItems);    // Do the sorting
  292. waste = mem - FreeMem();    // Is there a memory leak?
  293.  
  294. waste is non-zero, a very disturbing fact. But it gets even better,
  295. because on consecutive calls, waste IS zero. It looks as if
  296. malloc() remebers what it's done before. By the way, I need to
  297. use malloc() because the code has to be (sort of) platform independent.
  298.  
  299. The source is attached (hence the cross-posting to alt.sources.mac).
  300. It works, so feel free to use it. Something must be going wrong somewhere,
  301. I can't see it, can anybody else? I'm using THINK C 6.0.1 with Objects.
  302.  
  303. Thanks in advance folks!
  304.  
  305.  
  306. Chris
  307.  
  308. PS: a description of Radix Sort can be found in almost any books on
  309. algorithms
  310.  
  311. /********** Radix Sort Source *************************/
  312.  
  313. #define MAC
  314.  
  315. #ifdef MAC
  316. #define BYTE0 3
  317. #define BYTE1 2
  318. #define BYTE2 1
  319. #define BYTE3 0
  320. #endif
  321.  
  322. // for PC's or any other Big Endian...
  323. #ifdef PC
  324. #define BYTE0 0
  325. #define BYTE1 1
  326. #define BYTE2 2
  327. #define BYTE3 3
  328. #endif
  329.  
  330. #define kNumElements    500        // allocate space for 500 longs at a time
  331. #define kNumPasses        4                    // 32 bit longs - split into 4 * 8 bits
  332. #define kNumBuckets        256  // require 256 buckets
  333. #define kMaxBuffer        100            // sort at most 100 * 500 = 50000 items
  334.  
  335. typedef long    Buffer[kNumElements];    // we don't want to hammer the memory
  336. manager
  337. typedef Buffer    *BufferPtr;                                    // so we allocate space for 500 longs
  338.  
  339. typedef struct
  340.         {
  341.             BufferPtr        theBuffers[kMaxBuffer]; // hold the items as they are added
  342.             long            numItems;                                                                            // how many (filled) buffers have we
  343. got?
  344.             long            current;                                                                                // where does next item go?
  345.         } Bucket, *BucketPtr;
  346.         
  347.  
  348. static BucketPtr theBuckets[kNumBuckets];    // our buckets...
  349.  
  350.  
  351. // allocate space for the buckets and init
  352. void SetupBuckets(void)
  353. {
  354.     long    i, k;
  355.     
  356.     for (i = 0; i < kNumBuckets; i++)
  357.     {
  358.         theBuckets[i] = (BucketPtr) NewPtr(sizeof(Bucket));
  359.         
  360.         for (k = 0; k < kMaxBuffer; k++) theBuckets[i]->theBuffers[k] = NULL;
  361.         theBuckets[i]->numItems = 0;
  362.         theBuckets[i]->current = 0;
  363.     }
  364. }
  365.  
  366. // We're done, release memory
  367. void ClearBuckets(void)
  368. {
  369.     long    i, k;
  370.     
  371.     for (i = 0; i < kNumBuckets; i++)
  372.     {
  373.         for (k = 0; theBuckets[i]->theBuffers[k] != NULL; k++)
  374.         {
  375.             DisposPtr((Ptr) theBuckets[i]->theBuffers[k]);
  376.         }
  377.         DisposPtr((Ptr) theBuckets[i]);
  378.     }
  379. }
  380.  
  381. // Stuff what we've put into the buffers back into the array and release
  382. mem.
  383. void CopyBuckets(long theArray[])
  384. {
  385.     register long    i, j, k, l, count;
  386.     
  387.     count = 0;
  388.     for (i = 0; i < kNumBuckets; i++)
  389.     {
  390.         for (j = 0; j <= theBuckets[i]->numItems; j++) // number of filled
  391. buffers
  392.         {
  393.             if (j < theBuckets[i]->numItems) l = kNumElements; //full buffer
  394.             else l = theBuckets[i]->current;                                                                            //partially full
  395.             
  396.             for (k = 0; k < l; k++)
  397.             {
  398.                 theArray[count] = (*theBuckets[i]->theBuffers[j])[k];
  399.                 count++;
  400.             }
  401.          if (theBuckets[i]->theBuffers[j])
  402.             {
  403.                 free((void *) theBuckets[i]->theBuffers[j]);
  404.                 theBuckets[i]->theBuffers[j] = NULL;
  405.             }
  406.         }
  407.         theBuckets[i]->numItems = 0;
  408.         theBuckets[i]->current = 0;
  409.     }
  410. }
  411.  
  412.  
  413. void RadixSort(long theArray[], long numItems)
  414. {
  415.     register long    i, k;
  416.     register unsigned char    c;
  417.     short Offset[kNumPasses] = {BYTE0,BYTE1,BYTE2,BYTE3};
  418.      unsigned char *p;
  419.  
  420.     long    mem, waste;
  421.     
  422.     mem = FreeMem();
  423.     
  424.     SetupBuckets();
  425.     
  426.     for (i = 0; i < kNumPasses; i++)
  427.     {
  428.         for (k = 0; k < numItems; k++)
  429.         {
  430.             
  431.              p = (unsigned char *) &theArray[k] + Offset[i];
  432.              c = *p;
  433.             if (!theBuckets[c]->theBuffers[theBuckets[c]->numItems])
  434.             {
  435.                 theBuckets[c]->theBuffers[theBuckets[c]->numItems] = (BufferPtr)
  436. malloc(sizeof(Buffer));
  437.                 theBuckets[c]->current = 0;
  438.             }
  439.             
  440.             (*theBuckets[c]->theBuffers[theBuckets[c]->numItems])[theBuckets[c]->current]
  441. = theArray[k];
  442.             
  443.             theBuckets[c]->current++;
  444.             if (theBuckets[c]->current >= kNumElements)
  445.             {
  446.                 theBuckets[c]->numItems++;
  447.                 theBuckets[c]->current = 0;
  448.             }
  449.         }
  450.         CopyBuckets(theArray);
  451.     }
  452.     ClearBuckets();
  453.     waste = mem - FreeMem();
  454. }
  455.  
  456.  
  457.  
  458. +-----------------------------------------------------------------+
  459. |Chris Reid                            e-mail: cr@cs.strath.ac.uk |
  460. |Dept. Computer Science, Strathclyde University, Glasgow, Scotland|
  461. +-----------------------------------------------------------------+
  462.  
  463. +++++++++++++++++++++++++++
  464.  
  465. >From pcastine@jake.prz.tu-berlin.de (Peter Castine)
  466. Date: Mon, 6 Jun 1994 14:42:31 GMT
  467. Organization: PRZ TU-Berlin
  468.  
  469. cr@cs.strath.ac.uk (Chris Reid) writes:
  470. >
  471. >Hi everybody,
  472. >
  473. >I have written some code that implements Radix Sort (it sorts
  474. >an array of longs in linear time). It seems to work well enough,
  475. >but one thing is really strange: when I replace the NewPtr()
  476. >calls with calls to malloc(), the corresponding free() doesn't seem
  477. >to work. Here's roughly what happens:
  478. >
  479. [stuff deleted]
  480.  
  481. Well, as I remember, malloc() calls _NewPtr, but free() (at least
  482. in the THINK C implementation) does not (necessarily) call _DisposPtr.
  483. The malloc/free implementation does some of its own store management.
  484. So, what you're seeing is not (ahem, necessarily) a memory leak.
  485. Check the sources of malloc() and free() for details.
  486.  
  487. BTW, I've seen some code that checks the endian-ness of the machine
  488. at runtime. This might be a better idea than depending upon MAC
  489. or PC being #defined. The trick is to store an arbitrary value
  490. (like 0x1234) into a short, and looking at the first byte (by 
  491. typecasting the address of the variable to a char*). 
  492. Just a suggestion.
  493.  
  494. Cheers,
  495. -- 
  496. Peter Castine              | Dr. Who quote du jour:
  497. pcastine@prz.tu-berlin.de  |     Have you noticed the way people's
  498. ===========================| intelligence capabilities decline sharply
  499.  ``Have Mac, will travel'' | the minute they start waving guns around?
  500.  
  501. +++++++++++++++++++++++++++
  502.  
  503. >From isis@netcom.com (Mike Cohen)
  504. Date: Mon, 6 Jun 1994 17:05:40 GMT
  505. Organization: ISIS International
  506.  
  507. cr@cs.strath.ac.uk (Chris Reid) writes:
  508.  
  509. <snip>
  510.  
  511. >// RadixSort implemented using malloc() and free()
  512.  
  513. >mem = FreeMem();    // We've got amount 'mem' bytes in the heap
  514. >RadixSort(someArray, numItems);    // Do the sorting
  515. >waste = mem - FreeMem();    // Is there a memory leak?
  516.  
  517. >waste is non-zero, a very disturbing fact. But it gets even better,
  518. >because on consecutive calls, waste IS zero. It looks as if
  519. >malloc() remebers what it's done before. By the way, I need to
  520. >use malloc() because the code has to be (sort of) platform independent.
  521.  
  522. In most implementations of malloc/free, rather than simply calling NewPtr &
  523. DisposePtr directly, they will allocate a larger pool calling NewPtr as
  524. necessary and then manage the space in that pool. In most cases, this pool
  525. storage won't be returned to the mac memory manager, but will remain available
  526. for future malloc() calls. Therefore, FreeMem() will report that storage was
  527. lost.
  528. -- 
  529. Mike Cohen - isis@netcom.com
  530. NewtonMail, eWorld: MikeC / ALink: D6734 / AOL: MikeC20
  531. Home Page: file://ftp.netcom.com/pub/isis/home.html
  532.  
  533. +++++++++++++++++++++++++++
  534.  
  535. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  536. Date: Mon, 6 Jun 1994 21:11:22 GMT
  537. Organization: Apple Computer
  538.  
  539. Chris Reid, cr@cs.strath.ac.uk writes:
  540. > waste is non-zero, a very disturbing fact. But it gets even better,
  541. > because on consecutive calls, waste IS zero. It looks as if
  542. > malloc() remebers what it's done before. By the way, I need to
  543. > use malloc() because the code has to be (sort of) platform independent.
  544.  
  545. This is a very Frequently Asked Question. malloc and free as implemented by
  546. the ANSI library (on all know Mac development systems) grab large blocks of
  547. memory via NewPtr, then suballocate those blocks for successive mallocs.
  548. These large blocks don't get returned -- it would be difficult to figure out
  549. when to return them. But the memory in them does get re-used by malloc if you
  550. free it.
  551.  
  552. Think of it as if malloc and free create a new heap from which to allocate
  553. memory.
  554.  
  555. --Jens Alfke
  556.   jens_alfke@powertalk              Rebel girl, rebel girl,
  557.             .apple.com              Rebel girl you are the queen of my world
  558.  
  559. +++++++++++++++++++++++++++
  560.  
  561. >From hall_j@sat.mot.com (Joseph Hall)
  562. Date: Mon, 6 Jun 1994 18:48:45 GMT
  563. Organization: Motorola Inc., Satellite Communications
  564.  
  565. Seems it was cr@cs.strath.ac.uk (Chris Reid) who said:
  566. >Hi everybody,
  567. >
  568. >I have written some code that implements Radix Sort (it sorts
  569. >an array of longs in linear time). It seems to work well enough,
  570. >but one thing is really strange: when I replace the NewPtr()
  571. >calls with calls to malloc(), the corresponding free() doesn't seem
  572. >to work. Here's roughly what happens:
  573.  
  574. It used to be that THINK C's free() just didn't free blocks.  It
  575. was meant to work that way.  I don't recall whether it didn't free
  576. any blocks or whether it only freed blocks larger than a certain size.
  577.  
  578. MPW's malloc(), on the other hand, was busted around 3.0 or 3.1.
  579. Do some malloc-ing and some free-ing and eventually it would crash.
  580. I don't know whether that was ever fixed, though I reported it.
  581.  
  582. I suggest that you use NewPtr() on the Mac to obtain memory, then
  583. manage it with a memory allocator of your own.  The Aho/Hopcroft/
  584. Ullman algorithms book has a section on allocators, or you could
  585. just make allocations of the desired size with NewPtr().  You can always
  586. obtain a separate zone to work with, too, which makes it easy to
  587. free a whole bunch of stuff en masse.
  588.  
  589. -- 
  590. Joseph Nathan Hall | Joseph's Law of Interface Design: Never give your users
  591. Software Architect | a choice between the easy way and the right way.
  592. Gorca Systems Inc. |                 joseph@joebloe.maple-shade.nj.us (home)
  593. (on assignment)    | (602) 732-2549 (work)  Joseph_Hall-SC052C@email.mot.com
  594.  
  595. +++++++++++++++++++++++++++
  596.  
  597. >From Mark Hanrek <hanrek@cts.com>
  598. Date: Wed, 8 Jun 1994 00:53:17 GMT
  599. Organization: The Information Workshop
  600.  
  601. It seems to me that one should be able to copy the source code for
  602. malloc() and free() into their project, and then determine how to modify
  603. it to actually free the memory that was originally malloc'd.
  604.  
  605. This is what I figure I am going to have to do, because I just discovered
  606. that when I made this routine into a code resource (XCMD) which will run
  607. within HyperCard, it used malloc, and I absolutely must return that
  608. memory, and there is no way I could possibly convert the source code to
  609. using NewPtr without opening a Pandora's Box.  It's just too complex.
  610.  
  611. <sigh>
  612.  
  613. Mark Hanrek
  614.  
  615. +++++++++++++++++++++++++++
  616.  
  617. >From ray@sfu.ca (Ray Davison) (Ray Davison)
  618. Date: Fri, 10 Jun 1994 22:34:46 GMT
  619. Organization: Simon Fraser University
  620.  
  621. In article <Cr1zsu.K4G@crash.cts.com>, Mark Hanrek <hanrek@cts.com> wrote:
  622.  
  623. > It seems to me that one should be able to copy the source code for
  624. > malloc() and free() into their project, and then determine how to modify
  625. > it to actually free the memory that was originally malloc'd.
  626. > This is what I figure I am going to have to do, because I just discovered
  627. > that when I made this routine into a code resource (XCMD) which will run
  628. > within HyperCard, it used malloc, and I absolutely must return that
  629. > memory, and there is no way I could possibly convert the source code to
  630. > using NewPtr without opening a Pandora's Box.  It's just too complex.
  631.  
  632. I once needed to use some Unix code and also didn't want it to use malloc
  633. and free. All I did was include the following in the source:
  634.  
  635. #define free(p) DisposPtr((Ptr)(p))
  636. #define calloc(s,n) ((void *)NewPtrClear(s*n))
  637. #define malloc(s) ((void *)NewPtr(s))
  638.  
  639. Worked fine for me.
  640.  
  641. -- 
  642. Ray Davison
  643. ray@sfu.ca
  644.  
  645. +++++++++++++++++++++++++++
  646.  
  647. >From pcastine@tubprz.prz.tu-berlin.de (Peter Castine)
  648. Date: Sun, 12 Jun 1994 15:28:36 GMT
  649. Organization: PRZ TU-Berlin
  650.  
  651. ray@sfu.ca (Ray Davison) (Ray Davison) writes:
  652. >
  653. >I once needed to use some Unix code and also didn't want it to use malloc
  654. >and free. All I did was include the following in the source:
  655. >
  656. >#define free(p) DisposPtr((Ptr)(p))
  657. >#define calloc(s,n) ((void *)NewPtrClear(s*n))
  658.                                          ~~~~~
  659. >#define malloc(s) ((void *)NewPtr(s))
  660. >
  661. >Worked fine for me.
  662.  
  663. Just on principle, it might be a better idea to put parentheses
  664. around s and n in the macro {to wit: NewPtrClear((s)*(n)) }.
  665. It is, admittedly, a little rare to have complicated expressions 
  666. as parameters to calloc, but 't can happen.
  667.  
  668. Picky me ;-}
  669.  
  670. -- 
  671. Peter Castine              | Dr. Who quote du jour:
  672. pcastine@prz.tu-berlin.de  |     Have you noticed the way people's
  673. ===========================| intelligence capabilities decline sharply
  674.  ``Have Mac, will travel'' | the minute they start waving guns around?
  675.  
  676. ---------------------------
  677.  
  678. >From Jake_V._Bouvrie@bcsmac.org (Jake V. Bouvrie)
  679. Subject: Closing Down the FINDER
  680. Date: Sun,  5 Jun 94 11:52:50 EST
  681. Organization: (none)
  682.  
  683. Is it possible to quit the finder from your app, so that there isn't a finder to
  684. go to ?
  685.  
  686. +++++++++++++++++++++++++++
  687.  
  688. >From mclow@coyote.csusm.edu (Marshall Clow)
  689. Date: 5 Jun 1994 10:33:24 -0700
  690. Organization: California State University San Marcos
  691.  
  692. Jake V. Bouvrie (Jake_V._Bouvrie@bcsmac.org) wrote:
  693. >Is it possible to quit the finder from your app, 
  694. >so that there isn't a finder to go to ?
  695.  
  696. Sure, send it a 'quit' apple event.
  697. Under system 6 it's harder.
  698.  
  699. Marshall Clow
  700. Aladdin Systems
  701. mclow@san_marcos.csusm.edu
  702.  
  703.  
  704. +++++++++++++++++++++++++++
  705.  
  706. >From kenlong@netcom.com (Ken Long)
  707. Date: Sun, 5 Jun 1994 18:19:43 GMT
  708. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  709.  
  710. Do you mean in code or in practice?
  711.  
  712. -Ken-
  713.  
  714. +++++++++++++++++++++++++++
  715.  
  716. >From grobbins@apple.com (Grobbins)
  717. Date: 5 Jun 1994 17:03:01 -0700
  718. Organization: Skunkworks
  719.  
  720. In article <2st294$phj@coyote.csusm.edu>,
  721. Marshall Clow <mclow@coyote.csusm.edu> wrote:
  722. >Jake V. Bouvrie (Jake_V._Bouvrie@bcsmac.org) wrote:
  723. >>Is it possible to quit the finder from your app, 
  724. >>so that there isn't a finder to go to ?
  725. >Sure, send it a 'quit' apple event.
  726.  
  727. Not so fast; there are issues to consider.  Pasted
  728. below is the discussion from the Finder Q&A tech note
  729. (TB 535).
  730.  
  731. Grobbins             grobbins@apple.com
  732.  
  733. Usual disclaimers apply.
  734.  
  735. ______
  736.  
  737.  
  738. from Macintosh Technical Note TB 535 - Finder Q&As:
  739.  
  740. Quitting System 7 Finder
  741. Date Written:  4/17/92
  742. Last reviewed:  6/14/93
  743. I've been thinking of shutting down the System 7 Finder. Is this a cool
  744. thing to do in my application?
  745. ___
  746. We normally recommend that you don't quit the System 7 Finder application.
  747. Nevertheless, there may be a few good reasons to shut down the Finder. For
  748. example, the Installer (the only application Apple ships with a good reason
  749. to do so) sometimes needs to shut down the Finder and all other applications
  750. to make sure system resources aren't being used while they're being updated
  751. by the Installer.
  752.  
  753. If you find yourself in a situation where you need to shut down the Finder,
  754. you should know about a few things:
  755. * Before you shut down the System 7 Finder, use the Process Manager to see
  756. if the File Sharing Extension is running. If so, you should shut it down
  757. before shutting down the Finder. The File Sharing Extension shouldn't be
  758. running without the Finder because the Finder is the only user interface the
  759. File Sharing Extension has. You shouldn't take away the user interface to
  760. file sharing.
  761.  
  762.  There's another good reason to shut down the File Sharing Extension before
  763. the Finder. The Network Extension (not the Network control panel) handles
  764. all the user interface transactions among the Finder, the File Sharing
  765. Monitor control panel, the Sharing Setup control panel, the Users & Groups
  766. control panel, and the File Sharing Extension (the file server). The Network
  767. Extension opens another file, the Users & Groups Data File, so that it can
  768. manipulate users and groups. When you shut down the Finder (with a
  769. kAEQuitApplication Apple event), the Network Extension and its connection to
  770. the Users & Groups Data File are also closed (almost). Because of a minor
  771. bug in the system, the File Manager thinks that the file is closed and that
  772. the FCB used by that access path is free for reuse; however, the File
  773. Sharing Extension thinks the access path to the Users & Groups Data File
  774. from the Network Extension is still open. When the File Manager attempts to
  775. reuse that FCB to open another file later, the file is opened, but because
  776. the File Sharing Extension thinks that FCB is still in use by the Network
  777. Extension, it won't allow access to the file and it returns opWrErr (-49) to
  778. the Open call. At this point, the file that someone was attempting to open
  779. can't be accessed or closed.
  780.  
  781. * If the Finder is shut down and then eventually relaunched, there may be
  782. some fragmentation of the MultiFinder heap. This can occur because the
  783. Finder is the first application to be started, so it's always first in the
  784. MultiFinder heap. When you shut it down, that memory becomes available and
  785. other processes might occupy that space. When the Finder is restarted, if it
  786. can't get into its original space in the MultiFinder heap, it will get
  787. loaded somewhere else and probably won't be shut down again.
  788.  
  789. * In System 7, the Finder is responsible for filling the Apple menu with the
  790. items in the Apple Menu Items folder. When the Finder is gone, so are the
  791. Apple menu items, including things that are important to most users (like
  792. control panels).
  793.  
  794. * If the user has selected background printing with a LaserWriter or
  795. StyleWriter, nothing will print while the Finder is gone. That's because the
  796. Finder is responsible for monitoring the PrintMonitor Documents folder and
  797. launching the PrintMonitor application when necessary.
  798.  
  799.  
  800. +++++++++++++++++++++++++++
  801.  
  802. >From Jake_V._Bouvrie@bcsmac.org (Jake V. Bouvrie)
  803. Date: Sun,  5 Jun 94 21:31:29 EST
  804. Organization: (none)
  805.  
  806. >Do you mean in code or in practice?
  807. Well, i mean in Code, like i call it in my program....
  808.  
  809. +++++++++++++++++++++++++++
  810.  
  811. >From David_B._Lamkins@bmugbost.uu.holonet.net
  812. Date: Wed, 08 Jun 1994 14:29:18 EST
  813. Organization: BMUG Boston
  814.  
  815. Jake_V._Bouvrie@bcsmac.org (Jake V. Bouvrie) wrote:
  816.  
  817. >Is it possible to quit the finder from your app, so that there
  818. >isn't a finder to go to ?
  819.  
  820. Yes.  Assuming you don't mind that it's not a nice thing to do,
  821. you can use Process Manager calls (see IM VI or whatever new
  822. world volume has it) to kill the Finder.  You should also
  823. kill the background process that the File Sharing extension
  824. runs when sharing is turned on - to do otherwise risks
  825. corrupting the Users & Groups file.  This won't get rid of the
  826. Finder forever - it will restart as soon as all other
  827. applications quit.
  828.  
  829. Dave
  830. -BMUG Boston 617-721-5840, East Coast BBS of The World's Largest Mac User Group 
  831.  
  832. +++++++++++++++++++++++++++
  833.  
  834. >From wombat@claris.com (Scott Lindsey)
  835. Date: Wed, 08 Jun 1994 20:14:43 -0800
  836. Organization: Claris Corporation, Vancouver WA
  837.  
  838. In article <2stp3l$kf@apple.com>, grobbins@apple.com (Grobbins) wrote:
  839.  
  840. > In article <2st294$phj@coyote.csusm.edu>,
  841. > Marshall Clow <mclow@coyote.csusm.edu> wrote:
  842. > >Jake V. Bouvrie (Jake_V._Bouvrie@bcsmac.org) wrote:
  843. > >>Is it possible to quit the finder from your app, 
  844. > >>so that there isn't a finder to go to ?
  845. > >Sure, send it a 'quit' apple event.
  846. > Not so fast; there are issues to consider.  Pasted
  847. > below is the discussion from the Finder Q&A tech note
  848. > (TB 535).
  849.  
  850. Not to mention that PowerTalk has certain Finder dependencies.  There's
  851. lots of things that don't work if the Finder isn't running (or even if it
  852. gets relaunched!)  We ran into problems just using Apple's Installer. 
  853. After the Finder restarts, PowerTalk gets in a funny state where it's
  854. basically useless.
  855.  
  856. -- 
  857. Scott Lindsey <wombat@claris.com, wombat@apple.com>
  858. Std. disclaimer: my opinions, not Claris', not Apple's.
  859.  
  860. ---------------------------
  861.  
  862. >From "Andrew C. Plotkin" <ap1i+@andrew.cmu.edu>
  863. Subject: Fat-stripping
  864. Date: Thu,  2 Jun 1994 14:52:31 -0400
  865. Organization: Information Technology Center, Carnegie Mellon, Pittsburgh, PA
  866.  
  867. Which is to say, cutting a fat binary down to a 68K executable, thus
  868. saving space. And the parallel operation of cutting a fat binary down to
  869. a PowerMac executable. 
  870.  
  871. Someone must have written a tiny app to do this. Someone? Anyone? I just
  872. downloaded JPEGview 3.3, which is wonderful, but it looks like I can
  873. save half the disk space it takes up. This situation will continue to
  874. aggravate as fat binaries catch on.
  875.  
  876. (Reassurance: obviously, if I give anyone a copy of a shareware program
  877. which I have fat-stripped, I am obligated to tell them that fact and
  878. point them at an unadulterated version if they want it. Also, some
  879. shareware packages prohibit distributing altered copies at all, and this
  880. would certainly count as alteration. I think a well-behaved fat-stripper
  881. would append "68K" or "PMac" to the executable file name.)
  882.  
  883. If nobody has written this thing, I guess I will. The fat->68K stripper,
  884. anyhow. Unless it's non-trivial (which I guess is the only reason for it
  885. not being written.) Can one just reduce the data fork of the APPL to
  886. zero length, or is it trickier?
  887.  
  888. --Z
  889.  
  890. +++++++++++++++++++++++++++
  891.  
  892. >From tgaul@halcyon.com (Troy Gaul)
  893. Date: Fri, 03 Jun 1994 00:04:49 -0800
  894. Organization: Infinity Systems
  895.  
  896. In article <shvWdjy00gpIIUVOsF@andrew.cmu.edu>, "Andrew C. Plotkin"
  897. <ap1i+@andrew.cmu.edu> wrote:
  898.  
  899. > Which is to say, cutting a fat binary down to a 68K executable, thus
  900. > saving space. And the parallel operation of cutting a fat binary down to
  901. > a PowerMac executable. 
  902. > Someone must have written a tiny app to do this. Someone? Anyone? I just
  903. > downloaded JPEGview 3.3, which is wonderful, but it looks like I can
  904. > save half the disk space it takes up. This situation will continue to
  905. > aggravate as fat binaries catch on.
  906. >  
  907. > (Reassurance: obviously, if I give anyone a copy of a shareware program
  908. > which I have fat-stripped, I am obligated to tell them that fact and
  909. > point them at an unadulterated version if they want it. Also, some
  910. > shareware packages prohibit distributing altered copies at all, and this
  911. > would certainly count as alteration. I think a well-behaved fat-stripper
  912. > would append "68K" or "PMac" to the executable file name.)
  913. > If nobody has written this thing, I guess I will. The fat->68K stripper,
  914. > anyhow. Unless it's non-trivial (which I guess is the only reason for it
  915. > not being written.) Can one just reduce the data fork of the APPL to
  916. > zero length, or is it trickier?
  917.  
  918. I've written such a thing, mostly, anyway.  This type of program is much
  919. more complicated than it may first appear.  
  920.  
  921. The main reason I haven't released/finished mine is that I'm somewhat
  922. worried about the liability if the stripping process damages someone's
  923. application.  And it might be that the stripping will work fine, but if
  924. they try to run it later on the other type of machine, it might do
  925. something bad (rather than just fail to work).  This could be a problem
  926. that would take months, even years to develop, so the original copy might
  927. have been around for easy restoration.
  928.  
  929. Also, stripping 68K code is practically impossible to do safely for various
  930. reasons.
  931.  
  932. _troy gaul
  933.  infinity systems
  934.  
  935. +++++++++++++++++++++++++++
  936.  
  937. >From tgaul@halcyon.com (Troy Gaul)
  938. Date: Sat, 04 Jun 1994 22:14:44 -0700
  939. Organization: Infinity Systems
  940.  
  941. In article <scouten-030694090448@cactus.stu.umn.edu>,
  942. scouten@maroon.tc.umn.edu (Eric Scouten) wrote:
  943.  
  944. > You don't really have that much to worry about. If you're writing to strip
  945. > PowerPC code, you only have to read the 'cfrg' resource, find out where the
  946. > PowerPC code is, and get rid of it. In almost all cases, it will be in the
  947. > data fork -- though it is possible to put it in resources (or a *part* of
  948. > the data fork). Such cases are *very* rare, and unsupported by at least two
  949. > of the three major PowerPC development systems.
  950. > If you strip the PPC code properly, you can still launch the application on
  951. > a PPC machine; it'll just run in emulation mode instead. (Just be sure you
  952. > also remove the 'cfrg' resource!)
  953.  
  954. My program actually parses the 'cfrg' resource, and it is aware of the
  955. types of the blocks, etc. (for instance, when the Code Fragment Manager is
  956. implemented on 68K, it won't remove those).
  957.  
  958. The problem with stripping 68K code is that a PowerPC application might
  959. need some of the code resources if it has only been partially ported, and
  960. this is not described in the 'cfrg' resource or anywhere else.
  961.  
  962. _troy
  963. //////// //////___Troy Gaul_________________________tgaul@halcyon.com__ //
  964.   //    //       Infinity Systems ; Redmond, Washington                //
  965.  //    //  //  "Insert witty quote here."                             //
  966. //    //////________________________________________________________ //
  967.  
  968. +++++++++++++++++++++++++++
  969.  
  970. >From "Andrew C. Plotkin" <ap1i+@andrew.cmu.edu>
  971. Date: Mon,  6 Jun 1994 10:41:25 -0400
  972. Organization: Information Technology Center, Carnegie Mellon, Pittsburgh, PA
  973.  
  974. Thanks to everyone who replied. The generic answer seems to be "get
  975. IM-PPC System Software and look up the 'cfrg' resource," which I will do
  976. as soon as my other fifty-seven projects allow me some spare time.
  977.  
  978. --Z
  979.  
  980. "And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..."
  981.  
  982. +++++++++++++++++++++++++++
  983.  
  984. >From Ron_Hunsinger@bmug.org (Ron Hunsinger)
  985. Date: Sun, 12 Jun 94 08:55:52 PST
  986. Organization: Berkeley Macintosh Users Group
  987.  
  988. scouten@maroon.tc.umn.edu (Eric Scouten) writes:
  989.  
  990. >If you strip the 68K code properly, you can of course launch on a PPC
  991. >machine. If you attempt to launch such an app on a 68K machine, the Finder
  992. >will give you an error box saying something like "The application could not
  993. >be launched because an error of type -192 occurred." (-192 is resource not
  994. >found, probably the 'CODE 1' resource) This is harmless; it just means you
  995. >won't be able to use the app. (Unless they ever come out with PowerPC
  996. >emulation on 68K... snicker snicker!)
  997.  
  998. Or, you could substitute for the 68k code a tiny 68k program that puts up
  999. an alert saying "This program will not run on your machine because it has
  1000. been customized for PowerMac execution only."  Then you don't have to 
  1001. explain what "an error of type -192" means.
  1002.  
  1003. -Ron Hunsinger
  1004.  
  1005. ---------------------------
  1006.  
  1007. >From eshieh@volga.EECS.Berkeley.EDU (Eric Shieh)
  1008. Subject: Finder Comments and Finder Info Updating
  1009. Date: 9 Jun 1994 21:48:21 GMT
  1010. Organization: University of California, Berkeley
  1011.  
  1012.  
  1013. Hello all, there are a few minor quirks I'm trying to fix in my program.
  1014. First, how do you get the comments off of a floppy disk???IM VI says
  1015. it doesn't use the Desktop Manager for volumes < 2 megs, so you cant
  1016. use PBDTGetComment...I tried using the Morefiles routine, but it doesn't
  1017. seem to like floppies either...
  1018.  
  1019. Second problem: Is there any way to have the Finder update a file's label?
  1020. On a Powermac, whenever I set the label, then do a GetFInfo, the old label
  1021. is still returned, only when I close and re-open the folder does the label
  1022. get correctly set.  I tried "touching" the folder (usually used for
  1023. updating a file's icons) to no avail. This is annoying cuz my program
  1024. can read the label, but if the user changes it, then immediately give it to
  1025. my program, it'll read the old label still...
  1026.  
  1027. Thanks,
  1028. Eric
  1029. eshieh@cory.berkeley.edu
  1030.  
  1031.  
  1032. +++++++++++++++++++++++++++
  1033.  
  1034. >From leonardr@netcom.com (Leonard Rosenthol)
  1035. Date: Sun, 12 Jun 1994 23:13:14 GMT
  1036. Organization: Aladdin Systems, Inc.
  1037.  
  1038. In article <2t82n5$9g0@agate.berkeley.edu>, eshieh@volga.EECS.Berkeley.EDU
  1039. (Eric Shieh) wrote:
  1040.  
  1041. > Hello all, there are a few minor quirks I'm trying to fix in my program.
  1042. > First, how do you get the comments off of a floppy disk???IM VI says
  1043. > it doesn't use the Desktop Manager for volumes < 2 megs, so you cant
  1044. > use PBDTGetComment...I tried using the Morefiles routine, but it doesn't
  1045. > seem to like floppies either...
  1046.    Correct.  Floppies (volumes < 2 meg) use the old Sys6 style DTDB for
  1047. which there were no API calls for accessing the information.  Your only
  1048. option, if you MUST support it, is to figure out the format of the old
  1049. DTDB files and then read/write them...
  1050.  
  1051.  
  1052. > Second problem: Is there any way to have the Finder update a file's label?
  1053. >
  1054.    Not w/o a bunch of weird trap patches, nope.   
  1055.  
  1056.    The problem is that the Finder keeps certain things in an internal
  1057. "cache" and doesn't go back to disk (or doesn't flush it to disk) that
  1058. often.  There is also no (easy/approved/documented) way to get the Finder
  1059. to flush the cache, or reload the data.   There is an Apple event in the
  1060. new Scriptable Finder that allows you to force an "update" on a file, but
  1061. that doesn't help in all cases.
  1062.  
  1063.  
  1064. Leonard
  1065. - ------------------------------------------------------------------------
  1066. Leonard Rosenthol                      Internet:       leonardr@netcom.com
  1067. Director of Advanced Technology        AppleLink:      MACgician
  1068. Aladdin Systems, Inc.                  GEnie:          MACgician
  1069.  
  1070. ---------------------------
  1071.  
  1072. >From Neil Ticktin <publisher@xplain.com>
  1073. Subject: MacTech's ftp site now available!
  1074. Date: Thu, 9 Jun 1994 05:09:17 GMT
  1075. Organization: MacTech Magazine/Xplain Corp.
  1076.  
  1077. To all,
  1078.  
  1079. By popular demand (mostly from you folks on comp.sys.mac.programmer),
  1080. we've now established our ftp site.  To get to our files, do an anonymous
  1081. ftp to ftp.netcom.com and change directories to /pub/xplain -- there
  1082. you'll see our latest files.
  1083.  
  1084. In this site, we will regularly post the most recent 3 months of source
  1085. code to accompany the articles in the magazine.  That way, you can
  1086. download the info and play with the code as soon as you get the magazine.
  1087.  This brings our Internet support inline with our support on America
  1088. Online, CompuServe and AppleLink.
  1089.  
  1090. Please let us know if you have any suggestions.
  1091.  
  1092. Hope it helps,
  1093.  
  1094. Neil Ticktin
  1095. MacTech Magazine
  1096. - ---------------------------------------------------------------------
  1097.            Neil Ticktin, MacTech Magazine (formerly MacTutor)
  1098. PO Box 250055, Los Angeles, CA 90025 * 310-575-4343 * Fax: 310-575-0925
  1099.  For more info, anonymous ftp to ftp.netcom.com and cd to /pub/xplain
  1100.   custservice@xplain.com * editorial@xplain.com * adsales@xplain.com
  1101. marketing@xplain.com * accounting@xplain.com * pressreleases@xplain.com
  1102.    progchallenge@xplain.com * publisher@xplain.com * info@xplain.com
  1103.  
  1104. ---------------------------
  1105.  
  1106. >From Willie Abrams <willie-abrams@uokhsc.edu>
  1107. Subject: QuickDraw GX Display Devices
  1108. Date: 6 Jun 1994 19:03:50 GMT
  1109. Organization: OU Health Sciences Center
  1110.  
  1111. In working with GX, I was wondering -
  1112.  
  1113. When the graphics system gets loaded, I assume GX walks the 
  1114. list of GDevices known to QuickDraw, and creates viewDevices
  1115. for them...
  1116.  
  1117. Would it be possible to have GX draw to a display that was not
  1118. known to QuickDraw? That is, can GX recognize "GX" only display
  1119. hardware?
  1120.  
  1121. And since GX does allow for the definition and storage of 48 bit
  1122. per pixel data, could GX drive a special display board to help
  1123. drive us past the 8 bit grayscale ceiling. Maybe 16 bit grayscale
  1124. boards? :-)
  1125.  
  1126. This does have an application, really.
  1127.  
  1128. Many people in the medical imaging industry and some of our
  1129. customers (radiologists, etc.) believe that even though we have
  1130. been taught that the human eye can detect no more that 256 shades
  1131. of any given tone, that the ability to see 12 bits to 16 bits of
  1132. data is worthwhile and can make a difference on diagnosis. 
  1133.  
  1134.  
  1135. Willie Abrams                
  1136. Telemedicine Software Guy  Internet:  willie-abrams@uokhsc.edu
  1137. OU Health Sciences Center  AppleLink: Willie
  1138.  
  1139. +++++++++++++++++++++++++++
  1140.  
  1141. >From ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  1142. Date: 8 Jun 94 16:39:22 +1200
  1143. Organization: University of Waikato, Hamilton, New Zealand
  1144.  
  1145. In article <2svrum$dff@romulus.ucs.uoknor.edu>, Willie Abrams <willie-abrams@uokhsc.edu> writes:
  1146. >
  1147. > When the graphics system gets loaded, I assume GX walks the
  1148. > list of GDevices known to QuickDraw, and creates viewDevices
  1149. > for them...
  1150. >
  1151. > Would it be possible to have GX draw to a display that was not
  1152. > known to QuickDraw? That is, can GX recognize "GX" only display
  1153. > hardware?
  1154.  
  1155. GX can draw to offscreen ViewDevices, just like QuickDraw supports offscreen
  1156. GWorlds. They're easy to set up. You can even set up offscreen ViewGroups
  1157. (like the set of all screen devices is a ViewGroup), so you can draw a single
  1158. shape to multiple offscreen ViewDevices with a single GXDrawShape call.
  1159.  
  1160. > And since GX does allow for the definition and storage of 48 bit
  1161. > per pixel data, could GX drive a special display board to help
  1162. > drive us past the 8 bit grayscale ceiling. Maybe 16 bit grayscale
  1163. > boards? :-)
  1164.  
  1165. Unfortunately, last I checked in the (beta) documentation, GX cannot draw
  1166. _to_ a destination that has more than 8 bits per pixel component. I think it
  1167. can only read _from_ such a bitmap.
  1168.  
  1169. In short, you can certainly create and manipulate such a structure yourself,
  1170. no problem. And you can even get GX to display and print it (to within the
  1171. limits of your output hardware) once you've done. But GX will only be of
  1172. limited help with the manipulations.
  1173.  
  1174. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  1175. Info & Tech Services Division              fax: +64-7-838-4066
  1176. University of Waikato            electric mail: ldo@waikato.ac.nz
  1177. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+12:00
  1178.  
  1179. +++++++++++++++++++++++++++
  1180.  
  1181. >From Cary Clark <crclark@apple.com>
  1182. Date: Wed, 8 Jun 1994 04:42:51 GMT
  1183. Organization: Apple Computer, Inc.
  1184.  
  1185. In article <2svrum$dff@romulus.ucs.uoknor.edu> Willie Abrams,
  1186. willie-abrams@uokhsc.edu writes:
  1187. >Would it be possible to have GX draw to a display that was not
  1188. >known to QuickDraw? That is, can GX recognize "GX" only display
  1189. >hardware?
  1190.  
  1191. Yes. An application can create a device in with the gxScreenViewDevices
  1192. viewGroup (1), and then it will be treated like all other physical
  1193. devices. If nil is passed for the mapping to GXSetViewDeviceMapping, the
  1194. device will be located adjacent to but not overlapping the other physical
  1195. devices.
  1196.  
  1197. >And since GX does allow for the definition and storage of 48 bit
  1198. >per pixel data, could GX drive a special display board to help
  1199. >drive us past the 8 bit grayscale ceiling. Maybe 16 bit grayscale
  1200. >boards? :-)
  1201.  
  1202. Sorry, but GX does not allow for pixel sizes greater than 32 bits. Nor
  1203. does it provide for 16 bits/pixel grayscale. But both of these are fine
  1204. enhancement requests for version 2.0.
  1205.  
  1206. Cary Clark
  1207. Apple Computer, Inc.
  1208.  
  1209. ---------------------------
  1210.  
  1211. >From kaltwasc@ucs.orst.edu (Chris Kaltwasser)
  1212. Subject: SEMI-SUMMARY: Reading JPEGs (with code)
  1213. Date: 8 Jun 1994 03:45:29 GMT
  1214. Organization: Oregon State University, Corvallis
  1215.  
  1216. Hello all,
  1217.     A while ago, I asked for a little help/advice on decompressing
  1218. JPEGs from JFIF files using QuickTime, and I'm very pleased to be able to
  1219. report success.  For the benefit of the Mac programming community, here is
  1220. the product of my efforts:
  1221.  
  1222.     This routine reads a JPEG file into an offscreen GWorld.  It would
  1223. not be too difficult to modify it to use an onscreen port instead.  It
  1224. assumes you've already checked for QuickTime and so forth.  Permission is
  1225. given to use this code for non-commercial purposes.  Use at your own risk.
  1226.  
  1227. - ------------------Cut Here--------------------
  1228.  
  1229. //______________________________________________________________________
  1230. //
  1231. //    Code for reading and writing JFIF files for SSConverter 1.4.1
  1232. //
  1233. //    Copyright (c)1994 by Chris Kaltwasser.  All rights reserved.
  1234. //
  1235. //______________________________________________________________________
  1236.  
  1237.  
  1238.  
  1239. #include <ImageCompression.h>
  1240. #include <FixMath.h>
  1241.  
  1242.  
  1243.  
  1244. #define JFIF_ID_MARKER        0xE0
  1245. #define JFIF_INFO_MARKER    0xC0
  1246.  
  1247.  
  1248.  
  1249. OSErr ReadJPEGFile(FSSpec *spec, GWorldPtr *gw)
  1250. {
  1251.     Rect srcRect;
  1252.     GDHandle gdh;
  1253.     PixMapHandle pix;
  1254.     ImageDescriptionHandle descH;
  1255.     CGrafPtr port;
  1256.     Byte *data = NULL, *s, id[5] = "JFIF";
  1257.     long length, i;
  1258.     short j, refnum, err, width, height;
  1259.  
  1260.     if (*gw)
  1261.         DisposeGWorld(*gw);
  1262.     *gw = NULL;
  1263.  
  1264.     err = FSpOpenDF(spec, fsRdPerm, &refnum);
  1265.     if (!err)
  1266.     {
  1267.         err = GetEOF(refnum, &length);
  1268.         if (!err && length < 170L) err = kReadFailErr;
  1269.         if (!err)
  1270.         {
  1271.             data = (Byte*)NewPtr(length);
  1272.             if (!data) err = memFullErr;
  1273.         }
  1274.         if (!err)
  1275.             err = FSRead(refnum, &length, data);
  1276.         FSClose(refnum);
  1277.     }
  1278.  
  1279.     if (!err)
  1280.     {
  1281.         /* make sure data is JFIF data stream */
  1282.         for (i = 0; i < length; ++i)
  1283.             if (data[i] == 0xFF && data[i+1] == JFIF_ID_MARKER)
  1284.             {
  1285.                 for (s = &data[i+4], j = 0; j < 5; ++s, ++j)
  1286.                     if (*s != id[j])
  1287.                     {
  1288.                         err = kBadJFIFErr;
  1289.                         j = 5;
  1290.                     }
  1291.                 i = length;
  1292.             }
  1293.         if (err) goto abortJPEG;
  1294.  
  1295.         /* read JPEG height and width from JFIF stream */
  1296.         err = kBadJFIFErr;
  1297.         for (i = 0; i < length; ++i)
  1298.             if (data[i] == 0xFF && data[i+1] == JFIF_INFO_MARKER)
  1299.             {
  1300.                 height = data[i+5]*256 + data[i+6];
  1301.                 width = data[i+7]*256 + data[i+8];
  1302.                 err = noErr;
  1303.                 i = length;
  1304.             }
  1305.  
  1306.         if (!err)
  1307.         {
  1308.             srcRect.top = 0;
  1309.             srcRect.left = 0;
  1310.             srcRect.bottom = height;
  1311.             srcRect.right = width;
  1312.  
  1313.             err = NewGWorld(gw, 24, &srcRect, NULL, NULL, 0);
  1314.  
  1315.             GetGWorld(&port, &gdh);
  1316.             SetGWorld(*gw, NULL);
  1317.             ClipRect(&srcRect);
  1318.             ForeColor(blackColor);
  1319.             BackColor(whiteColor);
  1320.  
  1321.             descH = (ImageDescriptionHandle)NewHandle(sizeof(ImageDescription));
  1322.             HLock((Handle)descH);
  1323.             (**descH).idSize = sizeof(ImageDescription);
  1324.             (**descH).cType = 'jpeg';    
  1325.             (**descH).resvd1 = 0L;
  1326.             (**descH).resvd2 = 0;
  1327.             (**descH).dataRefIndex = 0;
  1328.             (**descH).version = 1;
  1329.             (**descH).revisionLevel = 1;
  1330.             (**descH).vendor = 'appl';
  1331.             (**descH).temporalQuality = 0;
  1332.             (**descH).spatialQuality = 0;
  1333.             (**descH).width = width;
  1334.             (**descH).height = height;
  1335.             (**descH).vRes = (**descH).hRes = Long2Fix(72L);
  1336.             (**descH).dataSize = length;
  1337.             (**descH).frameCount = 1;
  1338.             BlockMove("\pPhoto - JPEG", (**descH).name, 32L);
  1339.             (**descH).depth = 24;
  1340.             (**descH).clutID = -1;
  1341.             HUnlock((Handle)descH);
  1342.  
  1343.             pix = GetGWorldPixMap(*gw);
  1344.  
  1345.             if (LockPixels(pix))
  1346.             {
  1347.                 err = DecompressImage((Ptr)data, descH, pix, &srcRect, &srcRect,
  1348.                                     srcCopy, NULL);
  1349.                 UnlockPixels(pix);
  1350.             }
  1351.             else
  1352.                 err = memFullErr;
  1353.  
  1354.             SetGWorld(port, gdh);                    /* restore port and device */
  1355.  
  1356.             DisposeHandle((Handle)descH);
  1357.         }
  1358.     }
  1359.  
  1360. abortJPEG:
  1361.     if (data) DisposePtr((Ptr)data);
  1362.  
  1363.     return err;
  1364. }
  1365.  
  1366. ---------------------------
  1367.  
  1368. >From euajgo@eua.ericsson.se (Joakim Grebeno)
  1369. Subject: VBL interrupt & Stack Sniffer
  1370. Date: 10 Jun 1994 07:53:37 GMT
  1371. Organization: Ellemtel Telecom Systems Labs, Stockholm, Sweden
  1372.  
  1373. I can't, over my dead body, find the information describing how to
  1374. enable/disable the stack sniffer! It is supposed to be done by toggling
  1375. a number of system globals but I can't find the info neither in IM 1-6
  1376. nor in the technotes!
  1377.  
  1378. I have the same problem to find which slot in the exception table the
  1379. VBL interrupt occupies!
  1380.  
  1381. Any experiences?
  1382.  
  1383. Thanks in advance!
  1384. Joakim
  1385.  
  1386. --
  1387. Joakim Grebenoe
  1388.  
  1389.  
  1390. +++++++++++++++++++++++++++
  1391.  
  1392. >From bwade@graphics.cornell.edu (Bretton Wade)
  1393. Date: 10 Jun 1994 12:24:44 GMT
  1394. Organization: Program of Computer Graphics -- Cornell University
  1395.  
  1396. I did this once, there is only one low mem global (try 0x0110?) and it used to
  1397. have the name StackLowPt, but I can't find it in the headers anymore. anyway,
  1398. just write a zero to that location to disable the sniffer. 
  1399.  
  1400. BTW, it seems that the thread manager extension from apple already disables
  1401. the sniffer on a global basis. can anybody substantiate this? Protected mem
  1402. would be a better scheme...
  1403. -- 
  1404. _______________________________________________________________________________
  1405.  
  1406.    Bretton Wade (bw16@cornell.edu)
  1407.  
  1408.    Program of Computer Graphics
  1409.    580 Engineering and Theory Center
  1410.    Cornell University
  1411.    Ithaca, NY 14853
  1412.    Voice: (607) 255-6704
  1413.    Fax:   (607) 255-0806
  1414. _______________________________________________________________________________
  1415.  
  1416. +++++++++++++++++++++++++++
  1417.  
  1418. >From ari@world.std.com (Ari I Halberstadt)
  1419. Date: Fri, 10 Jun 1994 15:51:26 GMT
  1420. Organization: The World Public Access UNIX, Brookline, MA
  1421.  
  1422. In article <2t9661$fds@euas20.eua.ericsson.se>,
  1423. Joakim Grebeno <euajgo@eua.ericsson.se> wrote:
  1424. >I can't, over my dead body, find the information describing how to
  1425. >enable/disable the stack sniffer! It is supposed to be done by toggling
  1426. >a number of system globals but I can't find the info neither in IM 1-6
  1427. >nor in the technotes!
  1428.  
  1429. Set the low-memory global StkLowPt to 0.
  1430. -- 
  1431. Ari Halberstadt                                 ari@world.std.com
  1432. One generation passes away, and another generation comes: but the
  1433. earth abides for ever. -- Ecclesiastes, 1:4.
  1434.  
  1435. +++++++++++++++++++++++++++
  1436.  
  1437. >From ari@world.std.com (Ari I Halberstadt)
  1438. Date: Fri, 10 Jun 1994 15:52:52 GMT
  1439. Organization: The World Public Access UNIX, Brookline, MA
  1440.  
  1441. In article <2t9m2c$e6a@merckx.graphics.cornell.edu>,
  1442. Bretton Wade <bw16@cornell.edu> wrote:
  1443. >BTW, it seems that the thread manager extension from apple already disables
  1444. >the sniffer on a global basis. can anybody substantiate this? Protected mem
  1445. >would be a better scheme...
  1446.  
  1447. The last version of the TM (pre-2.0) that I checked just set StkLowPt to zero.
  1448. -- 
  1449. Ari Halberstadt                                 ari@world.std.com
  1450. One generation passes away, and another generation comes: but the
  1451. earth abides for ever. -- Ecclesiastes, 1:4.
  1452.  
  1453. +++++++++++++++++++++++++++
  1454.  
  1455. >From brad@tazboy.jpl.nasa.gov (Brad Pickering)
  1456. Date: 10 Jun 1994 17:59:29 GMT
  1457. Organization: Jet Propulsion Laboratory, Pasadena, CA
  1458.  
  1459. In article <2t9661$fds@euas20.eua.ericsson.se> euajgo@eua.ericsson.se (Joakim Grebeno) writes:
  1460.  
  1461.    Path: elroy.jpl.nasa.gov!lll-winken.llnl.gov!sol.ctr.columbia.edu!howland.reston.ans.net!EU.net!sunic!sics.se!eua.ericsson.se!eua.ericsson.se!euajgo
  1462.    From: euajgo@eua.ericsson.se (Joakim Grebeno)
  1463.    Newsgroups: comp.sys.mac.programmer
  1464.    Date: 10 Jun 1994 07:53:37 GMT
  1465.    Organization: Ellemtel Telecom Systems Labs, Stockholm, Sweden
  1466.    Lines: 16
  1467.    NNTP-Posting-Host: euas66c13.eua.ericsson.se
  1468.    Keywords: VBL, Stack Sniffer
  1469.  
  1470.    I can't, over my dead body, find the information describing how to
  1471.    enable/disable the stack sniffer! It is supposed to be done by toggling
  1472.    a number of system globals but I can't find the info neither in IM 1-6
  1473.    nor in the technotes!
  1474.  
  1475. Set the low memory global called 'StkLowPt' to 0.
  1476. #include <SysEqu.h>
  1477.  
  1478. *(long *)StkLowPt = 0;
  1479.  
  1480.    I have the same problem to find which slot in the exception table the
  1481.    VBL interrupt occupies!
  1482.  
  1483. I think this depends on which mac you have. On the original macs it
  1484. is handled by the autoint1 vector (0x64), which calls some code that
  1485. dispatches through the second entry of the level 1 dispatch table (Lvl1DT + 0x04).
  1486. Some of this is documented in IM II pg 197.
  1487.  
  1488.  
  1489. Brad Pickering
  1490.  
  1491. +++++++++++++++++++++++++++
  1492.  
  1493. >From cverret@vub.ac.be (Verret Chris)
  1494. Date: 11 Jun 1994 06:56:00 GMT
  1495. Organization: Brussels Free Universities (VUB/ULB), Belgium
  1496.  
  1497. Joakim Grebeno (euajgo@eua.ericsson.se) wrote:
  1498. : I can't, over my dead body, find the information describing how to
  1499. : enable/disable the stack sniffer! It is supposed to be done by toggling
  1500. : a number of system globals but I can't find the info neither in IM 1-6
  1501. : nor in the technotes!
  1502.  
  1503. The following did the trick for me:
  1504.  
  1505.  
  1506.  
  1507. Ptr      stkLowPt : 0x110;
  1508. Ptr      savedStkLowPt;
  1509.  
  1510.  
  1511.  
  1512. savedStkLowPt = stkLowPt;
  1513. stkLowPt = NULL;
  1514.  
  1515.  
  1516.  
  1517. stkLowPt = savedStkLowPt;
  1518.  
  1519. +++++++++++++++++++++++++++
  1520.  
  1521. >From jumplong@aol.com (Jump Long)
  1522. Date: 12 Jun 1994 15:44:01 -0400
  1523. Organization: America Online, Inc. (1-800-827-6364)
  1524.  
  1525. In article <2t9661$fds@euas20.eua.ericsson.se>,
  1526. euajgo@eua.ericsson.se (Joakim Grebeno) writes:
  1527.  
  1528. >I can't, over my dead body, find the information describing how to
  1529. >enable/disable the stack sniffer!
  1530.  
  1531. I put a code snippet on the Developer CD called "Switch Stack" that
  1532. shows how to let interrupt code run on a private stack.  It also
  1533. disables and re-enables the stack sniffer correctly.
  1534.  
  1535. - Jim Luther
  1536.  
  1537.  
  1538. ---------------------------
  1539.  
  1540. >From Patrick.Stadelmann@etudiants.unine.ch
  1541. Subject: Writing dcmd with Think C (Q)
  1542. Date: 8 Jun 94 15:04:44 MET
  1543. Organization: University of Neuchatel
  1544.  
  1545.  Hi !
  1546.  
  1547.  Is it possible to write a dcmd with Think C ? If I include the .0 librairies
  1548.  in my project, I get link errors (like DATA_INIT undefined, or something
  1549.  like that).
  1550.  
  1551.  Is there a Think C port of these librairies available somewhere ?
  1552.  
  1553.  Thanks for your help
  1554.  
  1555.  Patrick
  1556.  
  1557. +++++++++++++++++++++++++++
  1558.  
  1559. >From egurney@vcd.hp.com (Eddy J. Gurney)
  1560. Date: Wed, 8 Jun 1994 17:30:28 GMT
  1561. Organization: Hewlett-Packard VCD
  1562.  
  1563. Patrick.Stadelmann@etudiants.unine.ch wrote:
  1564. > Is it possible to write a dcmd with Think C ? If I include the .0 librairies
  1565. > in my project, I get link errors (like DATA_INIT undefined, or something
  1566. > like that).
  1567.  
  1568. > Is there a Think C port of these librairies available somewhere ?
  1569.  
  1570. Even if you do get your 'dcmd' to build under Think, you'll STILL need
  1571. MPW to run the "BuildDCMD" Tool which Apple kindly supplies only as an
  1572. MPW tool, without any source.
  1573.  
  1574. I was about to try the same thing as you when I realized this "gotcha".
  1575.  
  1576. However, if someone has come up with a method for building dcmd's under
  1577. Think, I would love to hear about it.
  1578.  
  1579. --
  1580. Eddy J. Gurney N8FPW   Hewlett-Packard Company, Vancouver (USA!) Division
  1581. egurney@vcd.hp.com                       #include <standard-disclaimer.h>
  1582. "Failures are divided into two classes-- those who thought and never did,
  1583.       and those who did and never thought."     John Charles Salak
  1584.  
  1585. +++++++++++++++++++++++++++
  1586.  
  1587. >From eascharf@u.washington.edu (Elizabeth Scharf)
  1588. Date: 9 Jun 1994 04:21:53 GMT
  1589. Organization: University of Washington, Seattle
  1590.  
  1591. I managed to get TC 5 to build dcmds by using custom headers.  The main 
  1592. file looked like this:
  1593.  
  1594. void    CommandEntry    (void);
  1595. void    main            (void);
  1596.  
  1597. void main (void) 
  1598. {
  1599.     asm {
  1600.         @valid_A4:
  1601.             dc.w    2
  1602.             dc.w    0
  1603.             lea        @valid_A4,a0
  1604.             bra        CommandEntry
  1605.         } /* asm */
  1606.  
  1607. }
  1608.  
  1609. (remember, for a custom header, put NOTHING else in this file!)
  1610.  
  1611. The main dcmd entrypoint looked like this:
  1612.  
  1613. #include <SetUpA4.h>
  1614. #include "dcmd.h"
  1615.  
  1616. pascal void CommandEntry (
  1617.  
  1618.     dcmdBlock    *paramPtr)
  1619.  
  1620.     { /* begin CommandEntry */
  1621.  
  1622.         RememberA0();
  1623.         SetUpA4();
  1624.         
  1625.         switch (paramPtr->request) {
  1626. ...
  1627.  
  1628.             } /* switch */
  1629.         
  1630.         RestoreA4();
  1631.         
  1632.     } /* end CommandEntry */
  1633.  
  1634. (and you even get globals!)
  1635.  
  1636. I think I used oconv on the dcmdGlue.Lib, but it was a while ago...
  1637.  
  1638. Hope this helps.
  1639.  
  1640. rmgw
  1641.  
  1642. This is not my account:  Please address replies to hawkfish@aol.com
  1643.  
  1644. Disclaimer:  All views expressed are entirely my own and do not reflect 
  1645. the opinions of Elizabeth Scharf or the University of Washington.
  1646.  
  1647. - ---------------------------------------------------------------------------
  1648. Richard Wesley             | A Capitalist is someone who   | "Intel Inside"
  1649. hawkfish@aol.com           | knows the price of everything | is a warning 
  1650. 71062.1711@compuserve.com  | and the value of nothing.     | label...
  1651. - ---------------------------------------------------------------------------
  1652.  
  1653.  
  1654. ---------------------------
  1655.  
  1656. End of C.S.M.P. Digest
  1657. **********************
  1658.  
  1659.  
  1660. ˇ